package org.ichihamigua.video.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.ichihamigua.common.video.entity.VideoBulletEntity;

import java.util.List;

/**
 * @author zzy
 */
@Mapper
public interface VideoBulletMapper extends BaseMapper<VideoBulletEntity> {
    @Select("SELECT vb.*, COUNT(vbl.video_id) * 0.4 + (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(vb.create_time)) / 3600.0 * 24 * 0.6 AS score\n" +
            "FROM ic_video_bullet as vb \n" +
            "LEFT JOIN ic_video_bullet_like as vbl \n" +
            "ON vb.id = vbl.bullet_id \n" +
            "WHERE vb.video_id = #{videoId}" +
            "GROUP BY vb.id \n" +
            "ORDER BY score DESC")
    List<VideoBulletEntity> selectBullet(Long videoId);
}
